# coding:UTF-8
# ________________________
# Project_Name:pyzidonghua
# File_Name:Administrator
# Author:Administrator
# Date_Time:2022/4/26 18:37
# Description:
# ______________________
import unittest  # 导入测试框架

from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait  # 导入显式等待类
from selenium.webdriver.support import expected_conditions  # 导入等待条件
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select


class IndexPage():

    # 定义属性
    def __init__(self, driver, wait):
        # 获取从用例层传入的driver和wait
        self.driver = driver
        self.wait = wait

        '''对操作元素及定位方式封装'''

        self.user_input_locator = (By.XPATH, '//*[@id="account"]/input')  # 账号输入框定位符
        self.pwd_input_locator = (By.XPATH, '//*[@id="password"]/input')  # 密码输入框定位符
        self.verif_input_locator = (By.XPATH,'//*[@id="authCode"]/div/input')  # 验证码输入框定位符
        self.login_btn_locator = (By.XPATH,'//*[@id="root"]/div/div[1]/form/div[5]/div/div/span/button')  # 点击登录
        self.click_recruit_locator = (By.XPATH, '//*[@id="root"]/section/aside/div/ul/li[1]/div') #点击招聘管理

        #  test1
        self.click_Data_entry_locator= (By.XPATH, '//*[@id="sale$Menu"]/li[5]')  # 点击数据录入
        self.click_template_locator = (By.XPATH, '//*[@id="root"]/section/section/main/div/div[1]/button[2]')  # 点击模板下载
        self.click_Import_locator = (By.XPATH, '//*[@id="root"]/section/section/main/div/div[1]/button[2]')  #点击导入
        self.click_add_to_locator = (By.XPATH, '//*[@id="root"]/section/section/main/div/div[2]/div/div[1]/div[1]')  # 点击手工添加
        self.click_add_name_locator = (By.XPATH, '//*[@id="name"]')  # 点击添加名字
        self.click_add_sex_locator = (By.ID, 'sex')  # 点击性别
        self.click_add_sex1_locator = (By.XPATH,"//*[text()='女']")
        self.click_add_priority_locator = (By.ID,'priority')  # 点击优先级
        self.click_add_priority1_locator = (By.XPATH, "//*[text()='中低']")
        self.click_add_channel_locator = (By.ID,'channelId')  # 点击渠道
        self.click_add_channel1_locator = (By.XPATH, "//*[text()='高校']")
        self.click_add_source_locator = (By.ID,'sourceId')  #点击渠道途径
        self.click_add_source1_locator = (By.XPATH, "//*[text()='高校招聘会']")
        self.click_add_product_locator = (By.XPATH, '//*[@id="trainType"]/div/div/div')  # 点击产品线
        self.click_add_product1_locator = (By.XPATH, "//*[text()='智慧停车场']")
        self.click_add_phone_locator = (By.XPATH, '//*[@id="phone"]')  # 点击输入手机号
        self.click_add_education_locator = (By.ID, 'degree')  # 点击学历
        self.click_add_education1_locator = (By.XPATH, "//*[text()='大专']")
        self.click_confirm_locator = (By.XPATH, '//*[@id="root"]/section/section/main/div/div[2]/div/div[2]/button') # 点击确认
        self.click_add_whole1_locator = (By.XPATH,'//*[@id="root"]/section/section/main/div/div[1]/div/div[1]/div') #点击全部
        self.click_add_whole11_locator = (By.XPATH, "//*[text()='上海']")  # 点击上海
        self.click_add_whole2_locator = (By.XPATH,'//*[@id="root"]/section/section/main/div/div[1]/div/div[2]/div/div') #点击全部
        self.click_add_whole21_locator = (By.XPATH, "//*[text()='中能上海']")  # 点击全部
        #test2
        self.click_resources_locator = (By.XPATH, '//*[@id="sale$Menu"]/li[3]')  # 点击资源管理
        self.click_tradition_locator = (By.XPATH, '//*[@id="resume$Menu"]/li[1]/a')  # 点击传统查询
        self.click_query_locator = (By.XPATH, '//*[@id="root"]/section/section/main/div/div[1]/button[1]')  # 点击查询
        self.input_name_locator = (By.XPATH, '// *[ @ id = "name"]')  # 输入姓名
        self.input_phone_locator = (By.XPATH, '//*[@id="phone"]')  # 输入电话号码
        self.click_query_Below_locator = (By.CSS_SELECTOR,'.ant-modal-footer>div>button:nth-child(2)')  # 点击下方查询

        self.click_choice_locator = (By.NAME,'张三')  # 点击单选框
        self.click_modify_locator = (By.XPATH, '//*[@id="root"]/section/section/main/div/div[1]/button[2]')  # 点击修改
        self.click_change_name_locator = (By.XPATH, '//input[@name="张三"]')  # 修改名字
        self.click_change_sex_locator = (By.XPATH, '//*[@id="sex"]/div/div')  # 修改性别
        self.click_change_sex1_locator = (By.XPATH, "//*[text()='男']")
        self.click_change_product_locator = (By.XPATH, '//*[@id="trainType"]/div/div')  # 修改产品线
        self.click_change_product1_locator = (By.XPATH, "//*[text()='智慧农业管理系统']")
        self.click_determine_locator = (By.CSS_SELECTOR,'.ant-modal-footer>button>span') #点击确定

    # 定义方法
    def input_user(self, username):
        """
        输入账号
        :return:
        """
        self.wait.until(expected_conditions.visibility_of_element_located(self.user_input_locator))
        el = self.driver.find_element(*self.user_input_locator)
        el.send_keys(username)

    def input_pwd(self, password):
        """
        输入密码
        :return:
        """
        self.wait.until(expected_conditions.visibility_of_element_located(self.pwd_input_locator))
        el = self.driver.find_element(*self.pwd_input_locator)
        el.send_keys(password)

    def input_verif(self,verif):
        """
        输入验证码
        :return:
        """
        self.wait.until(expected_conditions.visibility_of_element_located(self.verif_input_locator))
        el = self.driver.find_element(*self.verif_input_locator)
        el.send_keys(verif)

    def click_login(self):
        """
        点击登录
        :return:
        """
        self.wait.until(expected_conditions.visibility_of_element_located(self.login_btn_locator))
        el = self.driver.find_element(*self.login_btn_locator)
        el.click()

    def click_recruit(self):
        '''
        点击招聘管理
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_recruit_locator ))
        el = self.driver.find_element(*self.click_recruit_locator )
        el.click()

    def click_Data_entry(self):
        '''
        点击招数据录入
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_Data_entry_locator ))
        el = self.driver.find_element(*self.click_Data_entry_locator)
        el.click()

    def click_template(self):
        '''
        点击模板下载
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_template_locator ))
        el = self.driver.find_element(*self.click_template_locator)
        el.click()

    def click_Import(self,form):
        '''
        点击导入
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_Import_locator ))
        el = self.driver.find_element(*self.click_Import_locator)
        el.send_keys(form)

    def click_add_to(self):
        '''
        点击手工添加
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_to_locator ))
        el = self.driver.find_element(*self.click_add_to_locator)
        el.click()

    def click_add_name(self,name):
        '''
        点击添加姓名
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_name_locator ))
        el = self.driver.find_element(*self.click_add_name_locator)
        el.send_keys(name)

    def click_add_sex(self):
        '''
        点击添加性别
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_sex_locator))
        el = self.driver.find_element(*self.click_add_sex_locator)
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_sex1_locator))
        el = self.driver.find_element(*self.click_add_sex1_locator)
        el.click()

    def click_add_priority(self):
        '''
        点击添加优先级
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_priority_locator))
        el = self.driver.find_element(*self.click_add_priority_locator)
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_priority1_locator))
        el = self.driver.find_element(*self.click_add_priority1_locator)
        el.click()

    def click_add_channel(self):
        '''
        点击添加渠道
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_channel_locator))
        el = self.driver.find_element(*self.click_add_channel_locator )
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_channel1_locator))
        el = self.driver.find_element(*self.click_add_channel1_locator)
        el.click()

    def click_add_source(self):
        '''
        点击添加渠道途径
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_source_locator))
        el = self.driver.find_element(*self.click_add_source_locator )
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_source1_locator))
        el = self.driver.find_element(*self.click_add_source1_locator)
        el.click()


    def click_add_product(self):
        '''
        点击添加产品线
        :return:
        '''

        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_product_locator))
        el = self.driver.find_element(*self.click_add_product_locator)
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_product1_locator))
        el = self.driver.find_element(*self.click_add_product_locator)
        el.click()

    def click_add_phone(self,phone):
        '''
        点击输入手机号
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_phone_locator))
        el = self.driver.find_element(*self.click_add_phone_locator)
        el.send_keys(phone)

    def click_add_education(self):
        '''
        点击输入学历
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_education_locator))
        el = self.driver.find_element(*self.click_add_education_locator)
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_education1_locator))
        el = self.driver.find_element(*self.click_add_education1_locator)
        el.click()


    def click_add_whole1(self):
        '''
        点击全部1
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_whole1_locator))
        el = self.driver.find_element(*self.click_add_whole1_locator)
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_whole11_locator))
        el = self.driver.find_element(*self.click_add_whole11_locator)
        el.click()

    def click_add_whole2(self):
        '''
        点击全部2
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_whole2_locator))
        el = self.driver.find_element(*self.click_add_whole2_locator)
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_add_whole21_locator))
        el = self.driver.find_element(*self.click_add_whole21_locator)
        el.click()


    def click_confirm(self):
        '''
        点击确认
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_confirm_locator))
        el = self.driver.find_element(*self.click_confirm_locator)
        el.click()
    # ******************************************************
    def click_resources(self):
        '''
        点击资源管理
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_resources_locator))
        el = self.driver.find_element(*self.click_resources_locator)
        el.click()

    def click_tradition(self):
        '''
        点击传统简历
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_tradition_locator))
        el = self.driver.find_element(*self.click_tradition_locator)
        el.click()

    def click_query(self):
        '''
        点击查询
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_tradition_locator ))
        el = self.driver.find_element(*self.click_query_locator )
        el.click()

    def input_name(self,name):
        '''
        输入手机号
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.input_name_locator))
        el = self.driver.find_element(*self.input_name_locator)
        el.send_keys(name)

    def input_phone(self, phone):
         '''
         输入手机号
         :return:
         '''
         self.wait.until(expected_conditions.visibility_of_element_located(self.input_phone_locator))
         el = self.driver.find_element(*self.input_phone_locator)
         el.send_keys(phone)

    def click_query_Below(self):
         '''
         点击下方查询
         :return:
         '''
         self.wait.until(expected_conditions.visibility_of_element_located(self.click_query_Below_locator))
         el = self.driver.find_element(*self.click_query_Below_locator)
         el.click()

    def click_choice(self):
        '''
        点击单选框
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_choice_locator))
        el = self.driver.find_element(*self.click_choice_locator).is_selected()
        el.click()

    def click_modify(self):
        '''
        点击修改
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_modify_locator ))
        el = self.driver.find_element(*self.click_modify_locator )
        el.click()

    def click_change_name(self,name):
        '''
        点击修改姓名
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_change_name_locator ))
        el = self.driver.find_element(*self.click_change_name_locator )
        el.send_keys(name)

    def click_change_sex(self):
        '''
        点击修改性别
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_change_sex_locator))
        el = self.driver.find_element(*self.click_change_sex_locator )
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_change_sex1_locator))
        el = self.driver.find_element(*self.click_change_sex1_locator)
        el.click()

    def click_change_product(self):
        '''
        点击修改产品线
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_change_product_locator))
        el = self.driver.find_element(*self.click_change_product_locator )
        el.click()
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_change_product1_locator))
        el = self.driver.find_element(*self.click_change_product1_locator)
        el.click()


    def click_determine(self):
        '''
        点击确定
        :return:
        '''
        self.wait.until(expected_conditions.visibility_of_element_located(self.click_determine_locator))
        el = self.driver.find_element(*self.click_determine_locator )
        el.click()
    time.sleep(5)


if __name__ == "__main__":
    pass